<?php //pr($batchListData);?>
<!-- Add fancyBox main JS and CSS files -->
<?php
    echo $this->Html->script('fancybox/jquery.fancybox.js');
    echo $this->Html->css('fancybox/jquery.fancybox.css');
?>
<style type="text/css">
    .fancybox-custom .fancybox-skin {
            box-shadow: 0 0 50px #222;
    }
</style>
<div class="right-panel">
    <!--cont-top Start-->
    <div class="cont-top">
        <div class="left-cr"></div>
        <div class="right-cr"></div>
    </div>
    <!--cont-top End-->
    <!---left-nav Sart-->
    <div class="right-nav">
        <?php
        echo $this->session->flash();
        //echo $this->Form->create("ServiceUnit");
        ?>
        <h2>
            <?php echo __('PAYROLL_BATCH_MAINTENANCE'); ?>
            <span  class="back-align">
                <?php echo $this->html->link('<< ' . __('BACK', true), array('controller' => 'payrolls', 'action' => 'admin_verification_index'), array('div' => false, 'alt' => '<< ' . __('BACK', true), 'title' => '<< ' . __('BACK', true), 'class' => 'back-nav', 'escape' => false)); ?>
            </span>
        </h2>
        
        <!--register Starts-->
        <div class="register" style="border: none;">
            <h3 style="padding-top:10px;"><?php echo __('SELECTED_BATCH_DETAIL'); ?></h3>
            <!-- Div update starts here -->
            <div id="divUpdate">
                <?php echo $this->element('payrolls/admin_verification_payable_list');?>
            </div>
            <!-- Div update ends here -->

            <div class="form-padd" style="background: #ffffff;">
                <!--introduction Start-->
                <div class=" introduction">  
                    <table style="width:100%;">
                        <tr>
                            <td style="width:10%;"><strong><?php echo __('UNIT_CODE');?> :</strong> </td>
                            <td ><?php echo $batchListData['BatchList']['unit_code']; ?></td>
                        </tr>
                        
                        <tr>
                            <td colspan="2">
                                <?php 
                                    echo $this->Form->create("Payroll", array('action' => 'adminVerifierChangeStatus')); 
                                    echo $this->Form->hidden("Payroll.batch_list_id", array('value' => $batchListData['BatchList']['id'])); 
                                ?>
                                <table style="width:100%;" class="list" cellpadding="5">
                                    <tr>
                                        <th style="width:10%">&nbsp;</td>
                                        <th style="width:30%; text-align: left;"><strong><?php echo __('UNIT_APPROVED_BY'); ?></strong></th>
                                        <th style="width:30%; text-align: left;"><strong><?php echo __('CHECKING_BY'); ?></strong></th>
                                        <th style="width:30%; text-align: left;"><strong><?php echo __('CHECKED'); ?></strong></th>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td><?php echo ($batchListData['BatchList']['approved_by']) ? $usersData[$batchListData['BatchList']['approved_by']] : ''?></td>
                                        <td><?php echo ($batchListData['BatchList']['checker']) ? $usersData[$batchListData['BatchList']['checker']] : ''?></td>
                                        <td><?php echo ($batchListData['BatchList']['admin_checked']) ? $usersData[$batchListData['BatchList']['admin_checked']] : ''?></td>
                                    </tr>
                                    <tr>
                                        <td><?php echo __('DATE'); ?></td>
                                        <td><?php echo ($batchListData['BatchList']['approved_date'] != '0000-00-00') ? date('M j, Y', strtotime($batchListData['BatchList']['approved_date'])) :  __('YET_TO_APPROVE'); ?></td>
                                        <td><?php echo ($batchListData['BatchList']['check_date'] != '0000-00-00') ? date('M j, Y', strtotime($batchListData['BatchList']['check_date'])) :  __('YET_TO_CHECKING'); ?></td>
                                        <td><?php echo ($batchListData['BatchList']['admin_checked_date'] != '0000-00-00') ? date('M j, Y', strtotime($batchListData['BatchList']['admin_checked_date'])) :  __('YET_TO_CHECKED'); ?></td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td>&nbsp;</td>
                                        
                                        <td>
                                        <?php
                                        $checkClass = "";
                                        $disableCheckClass = "";
                                        $checkClassRevert = "";
                                        $disableCheckClassRevert = "";
                                        $checkedClass = "";
                                        $disableCheckedClass = "";
                                        $checkedClassRevert = "";
                                        $disableCheckedClassRevert = "";
                                        
                                        if($batchListData['BatchList']['checker'] == 0){
                                            $checkClassRevert = "disable";
                                            $disableCheckClassRevert = "return false";
                                            $checkedClass = "disable";
                                            $disableCheckedClass = "return false";
                                            $checkedClassRevert = "disable";
                                            $disableCheckedClassRevert = "return false";
                                        }
                                        
                                        if($batchListData['BatchList']['admin_checked'] != 0){
                                            $disableCheckClass = "return false";
                                            $checkClass = "disable";
                                            $checkClassRevert = "disable";
                                            $disableCheckClassRevert = "return false";
                                            $checkedClass = "disable";
                                            $disableCheckedClass = "return false";
                                        }
                                        
                                        if($roleId){//No checks for super admin
                                            if(!$showBatchRequestCheckURLAdminVerification){//Check if verify permissions is granted
                                                $disableCheckClass = "return false";
                                                $checkClass = "disable";
                                                $checkClassRevert = "disable";
                                                $disableCheckClassRevert = "return false";
                                                $checkedClass = "disable";
                                                $disableCheckedClass = "return false";
                                                $checkedClassRevert = "disable";
                                                $disableCheckedClassRevert = "return false";
                                            }                                            
                                        }
                                        
                                        if($batchListData['BatchList']['approved_by'] == 0){
                                            $disableCheckClass = "return false";
                                            $checkClass = "disable";
                                            $checkClassRevert = "disable";
                                            $disableCheckClassRevert = "return false";
                                            $checkedClass = "disable";
                                            $disableCheckedClass = "return false";
                                            $checkedClassRevert = "disable";
                                            $disableCheckedClassRevert = "return false";
                                        }
                                        
                                        if($batchListData['BatchList']['checker'] == 0){
                                            echo $this->Form->submit(__('CHECKING', true), array(
                                                "class" => "button ".$checkClass, 
                                                'label' => false, 
                                                'div' => false,
                                                'name' => 'checking',
                                                'onClick' => $disableCheckClass
                                                ));
                                            echo '<div class="buttonEnding"></div>';
                                        }elseif($batchListData['BatchList']['check_date'] != 0){
                                            echo $this->Form->submit(__('REVERT_CHECKING', true), array(
                                                "class" => "button ".$checkClassRevert, 
                                                'label' => false, 
                                                'div' => false,
                                                'name' => 'revert_checking',
                                                'onClick' => $disableCheckClassRevert
                                            ));
                                            echo '<div class="buttonEnding"></div>';
                                        }
                                        echo '</td><td >';
                                        if($batchListData['BatchList']['admin_checked'] == 0){
                                            echo $this->Form->submit(__('MARK_CHECKED', true), array(
                                                "class" => "button ".$checkedClass, 
                                                'label' => false, 
                                                'div' => false,
                                                'name' => 'checked',
                                                'onClick' => $disableCheckedClass
                                                ));
                                            echo '<div class="buttonEnding"></div>';
                                        }elseif($batchListData['BatchList']['admin_checked_date'] != 0){
                                            echo $this->Form->submit(__('REVERT_CHECKED', true), array(
                                                "class" => "button ".$checkedClassRevert, 
                                                'label' => false, 
                                                'div' => false,
                                                'name' => 'revert_checked',
                                                'onClick' => $disableCheckedClassRevert
                                            ));
                                            echo '<div class="buttonEnding"></div>';
                                        }
                                        
                                        /*
                                        if(!$roleId){
                                            if($batchListData['BatchList']['approved_by'] != 0 ){
                                                if($batchListData['BatchList']['checker'] == 0){
                                                    echo $this->Form->submit(__('CHECKING', true), array(
                                                        "class" => "button", 
                                                        'label' => false, 
                                                        'div' => false,
                                                        'name' => 'check'
                                                        ));
                                                    echo '<div class="buttonEnding"></div>';
                                                }elseif($batchListData['BatchList']['check_date'] != 0){
                                                    echo $this->Form->submit(__('CHECKED', true), array(
                                                        "class" => "button", 
                                                        'label' => false, 
                                                        'div' => false,
                                                        'name' => 'revert_check'
                                                    ));
                                                    echo '<div class="buttonEnding"></div>';
                                                }
                                            } else{
                                                echo $this->Form->submit(__('CHECKING', true), array(
                                                    "class" => "button disable", 
                                                    'label' => false, 
                                                    'div' => false,
                                                    'onClick' => 'return false;',
                                                ));
                                                echo '<div class="buttonEnding"></div>';
                                            }
                                        }elseif($showBatchRequestCheckURLAdminVerification){
                                            if($batchListData['BatchList']['approved_by'] != 0 ){
                                                if($batchListData['BatchList']['checker'] == 0){
                                                    echo $this->Form->submit(__('CHECKING', true), array(
                                                        "class" => "button", 
                                                        'label' => false, 
                                                        'div' => false,
                                                        'name' => 'check'
                                                        ));
                                                    echo '<div class="buttonEnding"></div>';
                                                }elseif($batchListData['BatchList']['check_date'] != 0){
                                                    echo $this->Form->submit(__('CHECKED', true), array(
                                                        "class" => "button", 
                                                        'label' => false, 
                                                        'div' => false,
                                                        'name' => 'revert_check'
                                                    ));
                                                    echo '<div class="buttonEnding"></div>';
                                                }
                                            } else{
                                                echo $this->Form->submit(__('CHECKING', true), array(
                                                    "class" => "button disable", 
                                                    'label' => false, 
                                                    'div' => false,
                                                    'onClick' => 'return false;',
                                                ));
                                                echo '<div class="buttonEnding"></div>';
                                            }
                                        }
                                        */
                                        ?>
                                        </td>
                                        
                                        
                                    </tr>
                                </table>
                                <?php echo $this->Form->end(); ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="width:100%" colspan="2">
                                 <?php echo $this->Form->create("Payroll", array('action' => 'download_view')); ?>
                                <table align="center" cellspacing="10"> 
                                    <tr>
                                        <td>
                                            <?php
                                                echo $this->Form->hidden("Payroll.batch_list_id", array('value' => $batchListData['BatchList']['id'])); 
                                                if(!$roleId){//No checks for superadmin
                                                    echo $this->Form->submit(__('PRINT_TO_PDF', true), array(
                                                            "class" => "button", 
                                                            'label' => false, 
                                                            'div' => false,
                                                            'name' => 'print_pdf'
                                                        ));
                                                    echo '<div class="buttonEnding"></div>';
                                                }elseif($showBatchRequestDownloadPDFURLAdminVerification){
                                                    echo $this->Form->submit(__('PRINT_TO_PDF', true), array(
                                                            "class" => "button", 
                                                            'label' => false, 
                                                            'div' => false,
                                                            'name' => 'print_pdf'
                                                        ));
                                                    echo '<div class="buttonEnding"></div>';
                                                }
                                            ?>    
                                        </td>
                                        <td>
                                            <?php
                                            if(!$roleId){//No checks for superadmin
                                                echo $this->Form->submit(__('PRINT_TO_EXCEL', true), array(
                                                    "class" => "button", 
                                                    'label' => false, 
                                                    'div' => false,
                                                    'name' => 'print_excel'
                                                ));
                                                echo '<div class="buttonEnding"></div>';
                                            }elseif($showBatchRequestDownloadExcelURLAdminVerification){
                                                echo $this->Form->submit(__('PRINT_TO_EXCEL', true), array(
                                                    "class" => "button", 
                                                    'label' => false, 
                                                    'div' => false,
                                                    'name' => 'print_excel'
                                                ));
                                                echo '<div class="buttonEnding"></div>';
                                            }
                                            ?>
                                        </td>
                                    </tr>
                                </table>
                                <?php echo $this->Form->end(); ?>
                            </td>
                        </tr>
                    </table>
                    
                </div>
                <!--introduction End-->
                <div class="clear"></div>
            </div>
        </div>        
    </div>
</div>
<script>   
    $(document).ready(function() {
        $('.fancybox').fancybox();
    });
    
</script>